﻿using MVCBootStrapShell_WithTheme.DAL;
using MVCBootStrapShell_WithTheme.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace MVCBootStrapShell_WithTheme.Controllers
{
    public class PageContentController : Controller
    {
        private SiteDataContext db = new SiteDataContext();
        
        // GET: PageContent
        public ActionResult Index()
        {
            return View(db.PageContents.ToList());
        }

        // GET: PageContent/Details/5
        public ActionResult Details(int id)
        {
            return View();
        }

        // GET: PageContent/Create
        public ActionResult Create()
        {
            return View();
        }

        // POST: PageContent/Create
        [HttpPost]
        //public ActionResult Create(FormCollection collection)
        public ActionResult Create([Bind(Include = "PageContentID,PageID,Text,PicturePath,PictureSize,PicturePosition")] PageContent pageContent)
        {        
            try
            {
                if (ModelState.IsValid)
                {
                    db.PageContents.Add(pageContent);
                    db.SaveChanges();
                    return RedirectToAction("Index");
                }
                

                return View(pageContent);
            }
            catch
            {
                return View();
            }
        }

        // GET: PageContent/Edit/5
        public ActionResult Edit(int id)
        {
            return View();
        }

        // POST: PageContent/Edit/5
        [HttpPost]
        public ActionResult Edit(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add update logic here

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }

        // GET: PageContent/Delete/5
        public ActionResult Delete(int id)
        {
            return View();
        }

        // POST: PageContent/Delete/5
        [HttpPost]
        public ActionResult Delete(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add delete logic here

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
    }
}
